﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;
using BusinessComponents.Managers;
using BusinessComponents.DomainModels;

namespace WaterfrontLodge.WebForms.Report
{
    public partial class RPT1001 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Chart1.ImageStorageMode = System.Web.UI.DataVisualization.Charting.ImageStorageMode.UseImageLocation;

            Chart1.Series["Series1"].ChartType = SeriesChartType.Column;
            Chart1.Series["Series1"].Color = System.Drawing.Color.Orange;
            Chart1.Titles[0].Text = "Top 5 Most Loyal Customers";
            Chart1.Titles[0].ToolTip = "List top 5 customers who have spent the most so far.";

            List<Report1001> list = (List<Report1001>)ManagerFactory.ReportMgr.fetchRpt1001();
            foreach(var rpt in list){
                int pos = Chart1.Series["Series1"].Points.AddXY(rpt.UserName, rpt.TotalAmt);
                Chart1.Series["Series1"].Points[pos].Label = rpt.TotalAmt.ToString();
            }

            Chart1.Series["Series1"]["DrawingStyle"] = "Cylinder";
            Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
            Chart1.DataBind();
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {

        }
        #endregion

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("/WebForms/Report/ReportList.aspx", true);
        }
    }
}